<template>
  <ve-line :data="chartData" :extend="extend"></ve-line>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  props: ['userId'],
  data () {
    this.extend = {
      series: {
        label: {
          normal: {
            show: true
          }
        },
        smooth: false
      }
      // //样式
      // textStyle: {
      //   color: '#BED1EF'
      // }
    }
    return {
      chartData: {
        columns: ['行为风格', '得分'],
        rows: [
          { 行为风格: 'D型', 得分: 0 },
          { 行为风格: 'I型', 得分: 0 },
          { 行为风格: 'S型', 得分: 0 },
          { 行为风格: 'C型', 得分: 0 }
        ]
      }
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  created () {
    this.selectproresult()
  },
  methods: {
    ...mapActions(['selectProresult']),
    selectproresult () {
      const params = {
        user_Id: this.userId,
        questionType_Id: 14
      }
      this.selectProresult(params)
        .then(data => {
          // console.log(data.data[0].resultStrength)
          this.chartData.rows[0].得分 = JSON.parse(data.data[0].countScore).D
          this.chartData.rows[1].得分 = JSON.parse(data.data[0].countScore).I
          this.chartData.rows[2].得分 = JSON.parse(data.data[0].countScore).S
          this.chartData.rows[3].得分 = JSON.parse(data.data[0].countScore).C
          this.$emit('resultStrength', data.data[0].resultStrength)
        })
    }
  }
}
</script>
